package com.hxit.servics.impl;

import com.hxit.mapper.AiModelMapper;
import com.hxit.mapper.ConversationsMapper;
import com.hxit.pojo.AIModel;
import com.hxit.pojo.Conversation;
import com.hxit.servics.AiModelService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LENOVO
 * @version 1.0
 * @date 2024/11/5 14:17
 */
@Service
public class AiModelImpl implements AiModelService {
@Autowired
private AiModelMapper aiModelMapper;
@Autowired
private ConversationsMapper conversationsMapper;
    @Override
    public void AddAiModels(AIModel aiModel) {
        aiModelMapper.AddModles(aiModel);
    }

    @Override
    public void DeleteModelsById(@Param("ids") List<Integer> ids) {
        for (Integer id : ids) {
            Conversation conversation = conversationsMapper.FindConversationById(id);
            if (conversation != null) {
                conversationsMapper.DeleteConversationsById(ids);
            }
            aiModelMapper.DeleteModelsById(ids);
        }
    }


    @Override
    public AIModel FindModelById(Integer id) {
        AIModel aiModel=aiModelMapper.FindModelById(id);
        return aiModel;
    }

    @Override
    public void UpdateAiModels(AIModel aiModel) {
        aiModelMapper.UpdateAiModels(aiModel);
    }
}

